<!-- 首页-部门管理-部门考勤-试用期考核 -->
<template>
  <div class="base-setting">
    <div class="wrap">
      <div class="header">
        <div>
          <a-input-search
            :style="{ width: '220px' }"
            placeholder="考核名称"
            search-button
            @search="onSearch"
            @press-enter="onSearch"
            v-model="nameSearch"
          />
        </div>
      </div>
      <table-turn :table-data="getTableData" ref="tableRef" :args="args">
        <a-table-column :width="80">
          <template #title> 序号 </template>
          <template #cell="{ rowIndex }">
            {{ rowIndex + 1 }}
          </template>
        </a-table-column>
        <a-table-column :width="200" data-index="name" title="事项编号">
        </a-table-column>
        <a-table-column :width="200" data-index="name" title="试用期考核名称">
        </a-table-column>
        <a-table-column :width="200" data-index="definition" title="考核周期">
        </a-table-column>
        <a-table-column :width="200" data-index="definition" title="创建人">
        </a-table-column>
        <a-table-column :width="200" data-index="definition" title="创建时间">
        </a-table-column>
        <a-table-column
          :width="200"
          data-index="definition"
          title="流程处理节点"
        >
        </a-table-column>
        <a-table-column
          :width="200"
          data-index="definition"
          title="考核确认状态"
        >
        </a-table-column>
        <a-table-column :width="200" data-index="" title="操作" fixed="right">
          <template #cell="{ record }">
            <a-tooltip content="处理">
              <IconFont
                type="icon-edit"
                :size="26"
                :style="{
                  marginRight: '10px',
                  cursor: 'pointer'
                }"
                @click="goEdit(record)"
              />
            </a-tooltip>
            <a-tooltip content="删除" position="left">
              <a-popconfirm
                content="是否确认删除该条数据?"
                position="left"
                @ok="del(record.id)"
              >
                <icon-font
                  type="icon-delete"
                  :size="26"
                  :style="{
                    cursor: 'pointer',
                    marginRight: '10px'
                  }"
                />
              </a-popconfirm>
            </a-tooltip>
          </template>
        </a-table-column>
      </table-turn>
    </div>
  </div>
</template>

<script lang="ts" setup>
const router = useRouter();

const props = withDefaults(
  defineProps<{
    state: number; // 状态 1待评价 2已评价 3抄送我的
  }>(),
  {}
);

let modalVisible = ref(false); // 判断新增弹出框是否打开
let currData = ref(); // 储存当前选中数据
let tableRef = ref();
let nameSearch = ref(''); // 搜索框的值

// 表格配置
const args = reactive({
  rowSelection: {
    type: 'checkbox',
    showCheckedAll: true,
    onlyCurrent: false
  }
});

// 获取表格数据
const getTableData = async () => {
  try {
    // originData.value = await GetHumanChangeSetting({
    //   typeId: 1 // 人事异动默认传1
    // });
    // const res: any = originData.value.find(
    //   (item: any) => item.id === currId.value
    // );
    // res.content = res.personnelChange;
    // return Promise.resolve(res.personnelChange);
  } catch (error: unknown) {
    console.log(error);
  }
};

// 点击搜索框
const onSearch = () => {
  refresh();
};

// 编辑
const goEdit = (record: any) => {
  console.log(record);
  currData.value = record;
  modalVisible.value = true;
};

// 删除某一行
const del = async (id: number) => {
  try {
    // await DelHumanChangeSetting({ id });
    refresh();
  } catch (error: unknown) {
    console.log(error);
  }
};

// 弹窗自定义事件
const indexEmit = async (record: any) => {
  //
};

// 刷新表格数据
const refresh = () => {
  tableRef.value.loadData();
};
</script>

<style scoped lang="less">
.wrap {
  // padding: 20px;

  .header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
  }
}
</style>
